package designpattern.staticfactorypattern;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hubb
 * @Date 2019/3/28 23:46
 */
public enum LoginEnum {
    /**
     * 密码
     */
    PASSWORD("password", new PasswordLogin()),
    PASSCODE("passcode", new DomainLogin());

    private static Map<String, Object> dict = new HashMap<String, Object>();

    static {
        for(LoginEnum loginEnum : LoginEnum.values()) {

            dict.put(loginEnum.getLoginType(), loginEnum.getObject());
        }
    }

    private String loginType;
    private Object object;

    LoginEnum(String loginType, Object object) {
        this.loginType = loginType;
        this.object = object;
    }

    public static Login getLoginEnum(String loginType) {
        return (Login) dict.get(loginType);
    }

    public String getLoginType() {
        return loginType;
    }

    public void setLoginType(String loginType) {
        this.loginType = loginType;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

}
